// const host = 'http://www.esunrising.net:8087/payment_api/'
const host = 'https://api.gm.gmread.cn/payment_api/'
// const host = 'http://192.168.1.187:8900/payment_api/'


const wxRequest = (params, url) => {
  wx.showNavigationBarLoading();
  wx.request({
    url: url,
    method: params.method || 'GET',
    data: params.data || {},
    header: params.header || {
      'Content-Type': 'application/json',
      'Authorization': wx.getStorageSync('userToken') ? wx.getStorageSync('userToken') : ''
    },
    success: (res) => {
      if (res.data.code == 403) {
        wx.clearStorageSync()
        wx.reLaunch({
          url: '/pages/login/login',
        })
      } else {
        params.success && params.success(res)
        wx.hideNavigationBarLoading()
      }
    },
    fail: (res) => {
      params.fail && params.fail(res)
    },
    complete: (res) => {
      params.complete && params.complete(res)
    }
  })
}

//到款列表
// const receiveList = (params) => wxRequest(params, host + 'receive/list');
//全部到款-获取“全部到款”记录清单
const getUnclaimedList = (params) => wxRequest(params, host + 'claim/getUnclaimedList');
//openid
const getXcxOpenId = (params) => wxRequest(params, host + 'xcx/getOpenId');
//未订阅
const wldwList = (params) => wxRequest(params, host + 'cus_subs/wldw');
//已订阅
const cus_subs_list = (params) => wxRequest(params, host + 'cus_subs/list');
//往来单位订阅操作
const call_cus = (params) => wxRequest(params, host + 'p_dk/call_cus');
//取消往来单位订阅操作
const cancel_cus = (params) => wxRequest(params, host + 'p_dk/cancel_cus');
//按类别获取已认领清单
const getClaimList = (params) => wxRequest(params, host + 'claim/getClaimList');
//到款认领-编辑页面-获取已关联发票清单
const getClaimInvoiceByClaimId = (params) => wxRequest(params, host + 'claim/getClaimInvoiceByClaimId');
//到款认领-编辑发票-获取发票信息
const getClaimInvoiceById = (params) => wxRequest(params, host + 'claim/getClaimInvoiceById');
//到款认领-编辑发票
const editClaimInvoice = (params) => wxRequest(params, host + 'claim/editClaimInvoice');
//到款认领-删除发票
const claimCancelInvoice = (params) => wxRequest(params, host + 'claim/claimCancelInvoice');
//到款认领-编辑页面-获取已关联任务清单
const getClaimTaskByClaimId = (params) => wxRequest(params, host + 'claim/getClaimTaskByClaimId');
//到款认领-编辑发票-获取任务信息
const getClaimTaskById = (params) => wxRequest(params, host + 'claim/getClaimTaskById');
//到款认领-编辑任务号
const editClaimTask = (params) => wxRequest(params, host + 'claim/editClaimTask');
//到款认领-删除任务号
const claimCancelTask = (params) => wxRequest(params, host + 'claim/claimCancelTask');
//到款认领-编辑页面-获取已关联合同清单
const getClaimContractByClaimId = (params) => wxRequest(params, host + 'claim/getClaimContractByClaimId');
//到款认领-编辑发票-获取合同信息
const getClaimContractById = (params) => wxRequest(params, host + 'claim/getClaimContractById');
//到款认领-编辑合同
const editClaimContract = (params) => wxRequest(params, host + 'claim/editClaimContract');
//到款认领-删除合同
const claimCancelContract = (params) => wxRequest(params, host + 'claim/claimCancelContract');
//到款认领-获取基本信息
const getClaimById = (params) => wxRequest(params, host + 'claim/getClaimById');
//获取认领审批流程
const getFlowByClaimId = (params) => wxRequest(params, host + 'claim/getFlowByClaimId');
//到款认领-关联发票-获取可关联发票清单
const claimSelectInvoice = (params) => wxRequest(params, host + 'claim/claimSelectInvoice');
//添加发票-确认添加
const claimRelateInvoice = (params) => wxRequest(params, host + 'claim/claimRelateInvoice');
//到款认领-提交操作
const submitClaim = (params) => wxRequest(params, host + 'claim/submitClaim');
//到款认领-保存操作
const saveClaim = (params) => wxRequest(params, host + 'claim/saveClaim');
//到款认领-再次提交操作
const resubmitClaim = (params) => wxRequest(params, host + 'claim/resubmitClaim');
//到款-银行到款详情
const getById = (params) => wxRequest(params, host + 'receive/getById');
//初次认领到款
const claimReceive = (params) => wxRequest(params, host + 'claim/claimReceive');
//到款认领-取消操作
const cancelClaim = (params) => wxRequest(params, host + 'claim/cancelClaim');
//到款认领审批-通过认领
const approveClaim = (params) => wxRequest(params, host + 'claim/approveClaim');
//到款认领审批-拒绝认领
const rejectClaim = (params) => wxRequest(params, host + 'claim/rejectClaim');
//获取可关联合同清单
const claimSelectContract = (params) => wxRequest(params, host + 'claim/claimSelectContract');
//认领关联合同
const claimRelateContract = (params) => wxRequest(params, host + 'claim/claimRelateContract');
//获取可关联任务号清单
const claimSelectTask = (params) => wxRequest(params, host + 'claim/claimSelectTask');
//认领关联任务
const claimRelateTask = (params) => wxRequest(params, host + 'claim/claimRelateTask');
//获取【到款类型】字典表
const getReceiveTypeDict = (params) => wxRequest(params, host + 'claim/getReceiveTypeDict');
//获取【归口部门】字典表
const getResponsibleDeptDict = (params) => wxRequest(params, host + 'claim/getResponsibleDeptDict');
//【到款认领】初次作废
const abolishClaim = (params) => wxRequest(params, host + 'claim/abolishClaim');
//获取【认领作废】单条数据
const getClaimAbolishDataById = (params) => wxRequest(params, host + 'claim/getClaimAbolishDataById');
//获取【认领作废】审批流
const getClaimAbolishFlow = (params) => wxRequest(params, host + 'claim/getClaimAbolishFlow');
//【暂存认领作废】（保存）
const saveAbolishClaim = (params) => wxRequest(params, host + 'claim/saveAbolishClaim');
//【提交认领作废】
const submitAbolishClaim = (params) => wxRequest(params, host + 'claim/submitAbolishClaim');
//【重新提交】认领作废流程
const resubmitAbolishClaim = (params) => wxRequest(params, host + 'claim/resubmitAbolishClaim');
//通过【认领作废申请】
const approveClaimAbolish = (params) => wxRequest(params, host + 'claim/approveClaimAbolish');
//拒绝【认领作废申请】
const rejectClaimAbolish = (params) => wxRequest(params, host + 'claim/rejectClaimAbolish');
//【删除认领作废】（也即取消作废）
const cancelClaimAbolish = (params) => wxRequest(params, host + 'claim/cancelClaimAbolish');
//【删除认领作废】（也即取消作废）
const getSubscribeNumber = (params) => wxRequest(params, host + 'cus_subs/getSubscribeNumber');
//往来单位--取消订阅
const customerUnsubscribe = (params) => wxRequest(params, host + 'cus_subs/customerUnsubscribe');
//往来单位--订阅
const customerSubscribe = (params) => wxRequest(params, host + 'cus_subs/customerSubscribe');
//副本-全部到款-获取【已订阅】“全部到款”记录清单
const getUnclaimedListSubs = (params) => wxRequest(params, host + 'claim/getUnclaimedListSubs');
//认领任务关联合同-【获取可关联合同列表】
const getClaimTaskContractList = (params) => wxRequest(params, host + 'claim/getClaimTaskContractList');
//认领任务号关联合同
const claimTaskRelateContract = (params) => wxRequest(params, host + 'claim/claimTaskRelateContract');
//openid登录
const loginByOpenId = (params) => wxRequest(params, host + 'login/loginByOpenId');
//获取到款类型
const querySysDictDataAll = (params) => wxRequest(params, host + 'sysDictData/querySysDictDataAll?coId=22&dictType=bank_type');
//逾期名单列表接口
const getScYqmdList = (params) => wxRequest(params, host + 'claim/getScYqmdList');
//白名单列表接口
const getYcBmdList = (params) => wxRequest(params, host + 'claim/getYcBmdList');





//获取【我的申请(近期申请)】清单
const getMyApplication = (params) => wxRequest(params, host + 'home/getMyApplication');
//获取【待审批(我的审批)】清单
const getMyExamine = (params) => wxRequest(params, host + 'home/getMyExamine');
//获取【我已审批】清单
const getMyExamineHistory = (params) => wxRequest(params, host + 'home/getMyExamineHistory');
//获取【我本部门已审批】清单
const getMyDeptExamineHistory = (params) => wxRequest(params, host + 'home/getMyDeptExamineHistory');
//到款认领 业务类型
const getDkBusinessType = (params) => wxRequest(params, host + 'claim/getDkBusinessType');
// 获取【_系统公告】清单 /home/getMyMessage
const getMyMessage = (params) => wxRequest(params, host + 'home/getMyMessage');

// 获取【_超期发票】清单 /home/getOverdueInvoice
const getOverdueInvoice = (params) => wxRequest(params, host + 'home/getOverdueInvoice');
// 获取【_待补录信息】清单/home/getUnfilledList
const getUnfilledList = (params) => wxRequest(params, host + 'home/getUnfilledList');



//系统公告-【删除消息】
const messageDelete = (params) => wxRequest(params, host + 'home/messageDelete');
//系统公告-设置【已读】
const messageSetRead = (params) => wxRequest(params, host + 'home/messageSetRead');
//通过ID获取【系统公告】单条记录
const getMessageById = (params) => wxRequest(params, host + 'home/getMessageById');
//获取【我的待办】清单
const getMyToDoList = (params) => wxRequest(params, host + 'home/getMyToDoList');
//获取首页基本信息【蓝色框内数量信息】
const getHomePageInfo = (params) => wxRequest(params, host + 'home/getHomePageInfo');
//首页搜索-模糊查询发票信息
const queryInvoice = (params) => wxRequest(params, host + 'home/queryInvoice');
//首页搜索-模糊查询到款信息
const queryReceive = (params) => wxRequest(params, host + 'home/queryReceive');
//批量通过审批
const batchApprove = (params) => wxRequest(params, host + 'home/batchApprove');
//批量拒绝审批
const batchDecline = (params) => wxRequest(params, host + 'home/batchDecline');
//认领作废
const getClaimAbolishDataList = (params) => wxRequest(params, host + 'claim/getClaimAbolishDataList');
//发票作废
const getListByType = (params) => wxRequest(params, host + 'invCancel/getListByType');






//发票列表
const invList = (params) => wxRequest(params, host + 'inv/getListByType')
//发票详情
const invDetails = (params) => wxRequest(params, host + 'inv/getInvDetail')
//发票复制
const invCopy = (params) => wxRequest(params, host + 'inv/invCopy')
//发票作废 -- 作废原因提交
const voidresSubmit = (params) => wxRequest(params, host + 'inv/cancelPassedInv')
//发票详情 -- 审批流程
const invProcess = (params) => wxRequest(params, host + 'inv/getInvProcess')
//发票详情 -- 作废审批流程
const voidinvProcess = (params) => wxRequest(params, host + 'inv/getInvCancelProcess')
//发票详情--编辑
const invEdit = (params) => wxRequest(params, host + 'inv/update')
//发票详情--审批意见 拒绝
const jujue = (params) => wxRequest(params, host + 'inv/invProcessApprovalReject')
//发票详情--审批意见 同意
const tongyi = (params) => wxRequest(params, host + 'inv/invProcessApprovalAgree')


//发票查询
const invSearch = (params) => wxRequest(params, host + 'inv/getListByAny')
//新建发票
const addNewinv = (params) => wxRequest(params, host + 'inv/contract/insertMultiple')
//删除发票
const delInv = (params) => wxRequest(params, host + 'inv/deleteById')
//新建发票 业务类型
const getBusinessTypeList = (params) => wxRequest(params, host + 'inv/getBusinessTypeList')
//新建发票 发票类型
const addNewinvType = (params) => wxRequest(params, host + 'inv/getInvTypeList')
//新建发票 到款类型
const getBankTypeList = (params) => wxRequest(params, host + 'inv/getBankTypeList')

//下一步 提交新建发票内容
const submitInv = (params) => wxRequest(params, host + 'inv/insertReturnId')
//新建发票 -- 号
const invNumber = (params) => wxRequest(params, host + 'user/getUserDeptById')
//新建开票内容--服务名称列表
const taskList = (params) => wxRequest(params, host + 'sysDictInvContent/querySysDictInvContentAll')
//新建开票内容--提交、保存
const newtask = (params) => wxRequest(params, host + 'inv/content/insertMultiple')
//新建开票内容--提交、保存 返回新建发票页面并回显
const newget = (params) => wxRequest(params, host + 'inv/getInvDetail')
//新建开票内容详情
const invcontentsDetails = (params) => wxRequest(params, host + 'inv/content/getById')
//新建开票内容详情--保存
const invcontentsSave = (params) => wxRequest(params, host + 'inv/content/update')
//新建发票页面 -- 开票删除
const delkaipiao = (params) => wxRequest(params, host + 'inv/content/deleteById')
//新建发票页面 -- 合同删除
const delhetong = (params) => wxRequest(params, host + 'inv/contract/deleteByIdStr')
//新建发票页面 -- 任务号分摊删除
const delfentan = (params) => wxRequest(params, host + 'inv/task/deleteById')
//新建发票页面 -- 任务号删除
const delrenwuhao = (params) => wxRequest(params, host + 'inv/task/deleteById')

//选择合同号页面--请求数据
const newBill = (params) => wxRequest(params, host + 'inv/contract/getContractList')
//选择合同号提交、确认
const newBillSub = (params) => wxRequest(params, host + 'inv/contract/insertMultiple')
//合同下的任务号分摊详情
const newBillDetails = (params) => wxRequest(params, host + 'inv/task/getById')
//合同下的任务号分摊详情--保存
const newBillSave = (params) => wxRequest(params, host + 'inv/task/update')

//新建发票--提交
const invSubmit = (params) => wxRequest(params, host + 'inv/invSubmitApproval')
//编辑发票--再次提交
const resubmit = (params) => wxRequest(params, host + 'inv/invResubmitApproval')

//任务号列表
const getInvSelectTaskList = (params) => wxRequest(params, host + 'inv/task/getInvSelectTaskList')
//任务号列表--确认
const insertMultiple = (params) => wxRequest(params, host + 'inv/task/insertMultiple')
//任务号详情
const renwuhaogetById = (params) => wxRequest(params, host + 'inv/task/getById')
//任务号详情 -- 保存
const renwuhaoupdate = (params) => wxRequest(params, host + 'inv/task/update')

//发票作废详情
const getInvCancelDetail = (params) => wxRequest(params, host + 'invCancel/getInvCancelDetail')
//发票作废 -- 保存
const getInvCancelupdate = (params) => wxRequest(params, host + 'invCancel/update')
//发票作废 -- 提交
const invCancelSubmitApproval = (params) => wxRequest(params, host + 'invCancel/invCancelSubmitApproval')
//发票作废 -- 再次提交
const invCancelResubmitApproval = (params) => wxRequest(params, host + 'invCancel/invCancelResubmitApproval')
const invCancelResSubmitApproval = (params) => wxRequest(params, host + 'invCancel/invCancelResubmitApproval')
//发票作废 -- 作废审批流程
const getInvCancelProcess = (params) => wxRequest(params, host + 'inv/getInvCancelProcess')
//发票作废--审批意见 拒绝
const voidjujue = (params) => wxRequest(params, host + 'inv/cancelInvProcessApprovalReject')
//发票作废--审批意见 同意
const voidtongyi = (params) => wxRequest(params, host + 'inv/cancelInvProcessApprovalAgree')
//发票作废-原因类型
const getCancelReasonTypeList = (params) => wxRequest(params, host + 'inv/getCancelReasonTypeList') 
//发票==补充信息
const fpbuchong = (params) => wxRequest(params, host + 'inv/updateById')
//发票作废==补充信息
const fpzfbuchong = (params) => wxRequest(params, host + 'invCancel/updateById')
//选择合同号 （fromTask）
const selectbill = (params) => wxRequest(params, host + 'inv/task/getSelectContractList')
//选择合同号 -- 确认（fromTask）
const selectbillConfirm = (params) => wxRequest(params, host + 'inv/task/update')


//新建合同 --选择往来单位列表
const getWldwList = (params) => wxRequest(params, host + 'sysCustomer/getWldwList')
//新建合同 --新增合同
const addSysDictContractOne= (params) => wxRequest(params, host + 'sysDictContract/addSysDictContractOne')
//新建往来单位 
const addSysCustomerOne= (params) => wxRequest(params, host + 'sysDictCustomer/addSysCustomerOne')
//新建往来单位 -- 列表
const getCustomerTypeDict= (params) => wxRequest(params, host + 'sysDictCustomer/getCustomerTypeDict')


//新建发票————新建往来单位 + -- 点击提交
const wldwupdate= (params) => wxRequest(params, host + 'inv/updateById ')
//新建发票/编辑发票 选择是否到款（是） 选择到款页--未认领
// const getUnclaimedList= (params) => wxRequest(params, host + '/claim/getUnclaimedList ')  ==同到款列表一个接口
//新建发票/编辑发票 选择是否到款（是） 选择到款页--已认领
const getDkClaimedList= (params) => wxRequest(params, host + 'claim/getDkClaimedList')
//发票-筛选条件-审批节点  
const getApprovalNodeList= (params) => wxRequest(params, host + 'inv/getApprovalNodeList')
// 发票-筛选条件-部门列表  get
const getDeptList= (params) => wxRequest(params, host + 'inv/getDeptList')
//编辑发票   开票内容总金额： GET
const sumMoneyByInvId= (params) => wxRequest(params, host + 'inv/content/sumMoneyByInvId')


//汇票付款
// 汇票付款列表
const getDraftList= (params) => wxRequest(params, host + 'fkDraft/getListByType')
// 汇票付款列表 未提交--删除
const draftListdel= (params) => wxRequest(params, host + 'fkDraft/deleteByIdStr')
// 汇票付款列表申请 下一步  fkDraft/insertReturnId{dfdwmc,  remarks}
const draftApplicationnext= (params) => wxRequest(params, host + 'fkDraft/insertReturnId')
// 汇票付款列表申请 页面回显
const draftgetFkDetail= (params) => wxRequest(params, host + 'fkDraft/getFkDetail')
// 汇票列表 -- 汇票删除list
const drafdelpiaoju= (params) => wxRequest(params, host + 'fkDraftClaim/deleteById')
// 汇票付款列表申请 -- 更新/保存
const draftApplicationSave = (params) => wxRequest(params, host + 'fkDraft/update');
// 汇票付款列表申请 -- 提交  
const draftApplicationSub = (params) => wxRequest(params, host + 'fkDraft/fkSubmitApproval');
// 汇票付款列表申请 -- 再次提交
const draftApplicationResSub = (params) => wxRequest(params, host + 'fkDraft/fkResubmitApproval');
// 添加关联汇票列表  
const draftaddoppUnitList = (params) => wxRequest(params, host + 'fkDraftClaim/getFkSelectPjList');
// 添加关联汇票列表 -- 确认
const draftaUnitLinMulti = (params) => wxRequest(params, host + 'fkDraftClaim/insertMultiple');
// 汇票详情 -- 审批流程
const draftProcess = (params) => wxRequest(params, host + 'fkDraft/getFkProcess');
// 汇票详情 -- 审批流程--同意
const draftProcessTongyi = (params) => wxRequest(params, host + 'fkDraft/fkProcessApprovalAgree');
// 汇票详情 -- 审批流程--拒绝
const draftProcessJujue = (params) => wxRequest(params, host + 'fkDraft/fkProcessApprovalReject');
// 编辑汇票 -- 关联汇票 汇票确认
const hpqueren = (params) => wxRequest(params, host + 'fkDraftClaim/confirmButton');
// 编辑汇票 -- 关联汇票 汇票取消
const hpquxioa = (params) => wxRequest(params, host + 'fkDraftClaim/cancelButton');



// 登录
const login = (params) => wxRequest(params, host + 'login/loginByPassword');
// 修改密码
const changePwd = (params) => wxRequest(params, host + 'user/changePassword');

module.exports = {
  hpqueren,
  hpquxioa,
  drafdelpiaoju,
  draftProcessJujue,
  draftProcessTongyi,
  draftProcess,
  draftgetFkDetail,
  draftaUnitLinMulti,
  draftaddoppUnitList,
  draftApplicationSub,
  draftApplicationResSub,
  draftApplicationSave,
  draftApplicationnext,
  draftListdel,
  getDraftList,
  sumMoneyByInvId,
  invCopy,
  getDeptList,
  getApprovalNodeList,
  getDkClaimedList,
  wldwupdate,
  getCustomerTypeDict,
  addSysCustomerOne,
  getWldwList,
  addSysDictContractOne,
  getCancelReasonTypeList,
  getBusinessTypeList,
  selectbillConfirm,
  selectbill,
  fpbuchong,
  fpzfbuchong,
  getUnfilledList,
  getOverdueInvoice,
  voidjujue,
  voidtongyi,
  getInvCancelDetail,
  getInvCancelProcess,
  invCancelSubmitApproval,
  invCancelResubmitApproval,
  invCancelResSubmitApproval,
  getInvCancelupdate,
  // receiveList,
  getBankTypeList,
  jujue,
  tongyi,
  renwuhaogetById,
  delrenwuhao,
  renwuhaoupdate,
  getInvSelectTaskList,
  insertMultiple,
  resubmit,
  getUnclaimedList,
  getXcxOpenId,
  wldwList,
  cus_subs_list,
  call_cus,
  getClaimList,
  getClaimInvoiceByClaimId,
  getClaimInvoiceById,
  editClaimInvoice,
  claimCancelInvoice,
  getClaimTaskByClaimId,
  getClaimTaskById,
  editClaimTask,
  claimCancelTask,
  getClaimContractByClaimId,
  getClaimContractById,
  editClaimContract,
  claimCancelContract,
  getClaimById,
  getFlowByClaimId,
  claimSelectInvoice,
  claimRelateInvoice,
  submitClaim,
  saveClaim,
  resubmitClaim,
  getById,
  claimReceive,
  cancelClaim,
  approveClaim,
  rejectClaim,
  claimSelectContract,
  claimRelateContract,
  claimSelectTask,
  claimRelateTask,
  getReceiveTypeDict,
  getResponsibleDeptDict,
  abolishClaim,
  getClaimAbolishDataById,
  getClaimAbolishFlow,
  saveAbolishClaim,
  submitAbolishClaim,
  resubmitAbolishClaim,
  approveClaimAbolish,
  rejectClaimAbolish,
  cancelClaimAbolish,
  getSubscribeNumber,
  customerUnsubscribe,
  customerSubscribe,
  getUnclaimedListSubs,
  getClaimTaskContractList,
  claimTaskRelateContract,
  loginByOpenId,
  querySysDictDataAll,
  getScYqmdList,
  getYcBmdList,


  getMyApplication,
  getMyExamine,
  getMyExamineHistory,
  getMyDeptExamineHistory,
  getDkBusinessType,
  getMyMessage,
  messageDelete,
  messageSetRead,
  getMessageById,
  getMyToDoList,
  getHomePageInfo,
  queryInvoice,
  queryReceive,
  batchApprove,
  batchDecline,
  getClaimAbolishDataList,
  getListByType,



  delhetong,
  delkaipiao,
  delfentan,
  voidinvProcess,
  invSubmit,
  voidresSubmit,
  newBillDetails,
  newBillSave,


  


  cancel_cus,
  invList,
  invcontentsSave,
  login,
  invSearch,
  addNewinv,
  delInv,
  addNewinvType,
  login,
  submitInv,
  invNumber,
  invProcess,
  invEdit,
  newtask,
  newget,
  invcontentsDetails,
  taskList,
  newBill,
  newBillSub,
  invDetails,
  login,
  changePwd
}